
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

# 创建网格数据

# 使用 loadtxt 读取文件
data_X = np.loadtxt('output/model_landing_6dof/iteration000_X.txt', dtype=float)
data_U = np.loadtxt('output/model_landing_6dof/iteration000_U.txt',dtype=float)

data_X = data_X.transpose()
data_U = data_U.transpose()
#print(data_U)
#print(data_X)
r_i  = data_X[:,2:5]
u = data_U
# print(r_i)
# print(u)

# 创建图形
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.scatter(r_i[:,0], r_i[:,1], r_i[:,2], color='blue')

ax.quiver(r_i[:,0],r_i[:,1],r_i[:,2],u[:,0],u[:,1],u[:,2],length = 0.02, normalize = True, color='red')

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('3D Vector Field')

# ax.

# 显示图形
plt.show()



